
#include "stdafx.h"
#include "GeneImp.h"



GeneImp::GeneImp()
:m_nID(0), 
m_nMutexRule(0), 
m_nMutexGroup(0),
m_nTTL(0)
{

}

int		
GeneImp::getID()const
{
	return m_nID;
}

int		
GeneImp::getMutexRule()const
{
	return m_nMutexRule;
}

int
GeneImp::getMutexGroup()const
{
	return m_nMutexGroup;
}

int		
GeneImp::getDuration()const
{
	return m_nTTL;
}

IData*	
GeneImp::getStaticData()
{
	return m_wpSData;
}




bool
GeneImp::onInit(IGeneCreateData& createData)
{
	m_wpSData = createData.getStaticData();
	if (m_wpSData)
	{

		if (createData.getDuration())
		{
			m_nTTL = createData.getDuration();
		}
		else
		{
			m_nTTL = m_wpSData->getDataX();
		}


		m_nID = m_wpSData->getID();
		//m_nClass = m_wpSData->getGroupID();
		m_nMutexRule = m_wpSData->getDataX();
		m_nMutexGroup = m_wpSData->getDataY();
		m_nTTL = m_wpSData->getDataZ();

		return true;
	}
	
	return false;
}

bool
GeneImp::onAttach()
{
	return true;
}

bool
GeneImp::onDetach()
{
	return true;
}

bool
GeneImp::onUpdate(const int& nElapse)
{
	if (m_nTTL!=0)
	{
		m_nTTL -= nElapse;
		return m_nTTL<=0;
	}
	return true;
}

void
GeneImp::onEvent(IEvt& evt)
{
}